//
//  LeftDrawerViewController.m
//  LightningReimbursement
//
//  Created by 企点点 on 15/8/4.
//  Copyright (c) 2015年 企点点. All rights reserved.
//

#import "LeftDrawerViewController.h"
#import "BaseInfoViewController.h"
#import "DDMenuController.h"
#import "AppDelegate.h"
@interface LeftDrawerViewController ()

@end

@implementation LeftDrawerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:244 / 255.0 green:244  / 255.0 blue:244 / 255.0 alpha:1];
//    self.view.alpha = 0.5;
    
    // 头像图片
    UIImage *image = [UIImage imageNamed:@"55"];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(60, 50, 120, 120);
    button.backgroundColor = [UIColor greenColor];
//    [button setImage:image forState:UIControlStateNormal];
//    [button setImage:image forState:UIControlStateHighlighted];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    // 为头像按钮添加响应方法
    [button addTarget:self action:@selector(handleAvatarButton) forControlEvents:UIControlEventTouchUpInside];
    // 把头像变成圆形的
    button.layer.cornerRadius = 60;
    button.clipsToBounds = YES;

    
    [self.view addSubview:button];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 50 + 120 + 5, 120, 30)];
    label.text = @"娄迎迎";
    label.font = [UIFont systemFontOfSize:15 weight:15];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor purpleColor];
    [self.view addSubview:label];
    
    // 调用添加按钮的方法
    [self _setUpButton];
    
}

// 头像按钮的实现方法
- (void)handleAvatarButton {
    
    DDMenuController *menuController = (DDMenuController *)self.view.window.rootViewController;
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UINavigationController *naviC = (UINavigationController *)delegate.drawer.rootViewController;
    
    NSLog(@"888888888888");
    BaseInfoViewController *baseInfoVC = [[BaseInfoViewController alloc] init];
    [naviC pushViewController:baseInfoVC animated:YES];
    [menuController showRootController:YES];
    naviC.navigationItem.title = @"娄迎迎";
}


// 按钮
- (void)_setUpButton {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 50 + 120 + 5 + 50, 240, 240)];
//    view.backgroundColor = [UIColor lightGrayColor];
//    view.center = self.view.center;
    [self.view addSubview:view];
    //在自定义的View上面添加四个一样大的按钮
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    NSArray *arrayTitle = @[@"首页", @"设置", @"示例企业", @"退出"];
    button1.frame = CGRectMake(0, 0, 120, 120);
    [button1 setTitle:arrayTitle[0] forState:UIControlStateNormal];
    // 按钮标题的颜色
    [button1 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setTitle:arrayTitle[1] forState:UIControlStateNormal];
    button2.frame = CGRectMake(120, 0, 120, 120);
    // 按钮标题的颜色
    [button2 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    // 把view 的颜色设置为白色
    view.backgroundColor = [UIColor whiteColor];
    
    // 按钮之间垂直分割线
    UIView *separateLine1 = [[UIView alloc] initWithFrame:CGRectMake(120, 0, 0.3, 240)];
    separateLine1.backgroundColor = [UIColor lightGrayColor];
    [view addSubview:separateLine1];
    // 按钮之间的水平分割线
    UIView *separateLine3 = [[UIView alloc] initWithFrame:CGRectMake(0, 120, 0.3, 240)];
    separateLine3.backgroundColor = [UIColor lightGrayColor];
    [view addSubview:separateLine3];
    
//    button1.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    button3.frame = CGRectMake(0, 120, 120, 120);
    [button3 setTitle:arrayTitle[2] forState:UIControlStateNormal];
    
    // 按钮标题的颜色
    [button3 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    
    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
    button4.frame = CGRectMake(120, 120, 120, 120);
    [button4 setTitle:arrayTitle[3] forState:UIControlStateNormal];
    // 按钮标题的颜色
    [button4 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    
    // 添加到view上
    [view addSubview:button1];
    [view addSubview:button2];
    [view addSubview:button3];
    [view addSubview:button4];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
